package cn.com.woxitech.dev.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.woxitech.dev.dao.gen.WmLectureMapper;
import cn.com.woxitech.dev.model.gen.WmLecture;
import cn.com.woxitech.dev.model.gen.WmLectureExample;

@Service
public class LectureService {
	@Autowired
	WmLectureMapper lectureMapper;
	
	public WmLecture getLectureByRoomUuid(String roomUuid) {
		WmLectureExample example = new WmLectureExample();
		example.createCriteria().andRoomidEqualTo(roomUuid);
		List<WmLecture> list = lectureMapper.selectByExample(example);
		if (list.isEmpty()) {
			return null;
		}else {
			return list.get(0);
		}
	}
	public void insertLecture(WmLecture lecture) {
		lectureMapper.insertSelective(lecture);
	}
	
	public void updateByPrimaryKey(WmLecture lecture) {
		lectureMapper.updateByPrimaryKeySelective(lecture);
	}
	public List<WmLecture> getLectureListByRooms(List<String> roomStrs) {
		
		if(roomStrs == null || roomStrs.isEmpty())
			return null;
		
		WmLectureExample example = new WmLectureExample();
		example.createCriteria().andRoomidIn(roomStrs);
		example.setOrderByClause("id desc");
		List<WmLecture> list = lectureMapper.selectByExample(example);
		return list;
	}
	public void deleteByRoomUuid(String uuid) {
		// TODO Auto-generated method stub
		
		WmLectureExample example = new WmLectureExample();
		example.createCriteria().andRoomidEqualTo(uuid);
		lectureMapper.deleteByExample(example);
	}
}
